package TCP;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class SeverDemo02 {
    public static void main(String[] args) throws IOException {
        //创建服务器对象（SeverSocket)
        //SeverSocket (int port)创建绑定到指定端口的服务器套接字
        ServerSocket ss=new ServerSocket(10086);

        //accept()监听要链接到此套接字，并接收他
        //监听客户端的链接，返回一个Socket对象
        Socket s=ss.accept();

        //获取输入流
//        InputStream is = s.getInputStream();
//        InputStreamReader isr=new InputStreamReader(is);
//        BufferedReader br=new BufferedReader(isr);
        BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
        String line;
        while ((line=br.readLine())!=null){
            System.out.println(line);
        }

//        s.close();
        ss.close();
    }
}
